//
//  CreateGroupVC.m
//  LeftRightSlider
//
//  Created by QQ on 15-8-17.
//  Copyright (c) 2015年 heroims. All rights reserved.
//

#import "CreateGroupVC.h"
#import "MainViewController.h"

@interface CreateGroupVC ()

@property (nonatomic, strong) UILabel *titleTextLb;
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation CreateGroupVC

- (void)viewDidLoad {
    [super viewDidLoad];

    {
        self.navigationController.navigationBar.hidden = YES;
        
        UIView *indicateView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 320, NAVIGATION_CONTROLLER_HEIGHT)];
        
        //Title区域显示标题
        self.titleTextLb = [[UILabel alloc] init];
        // 左导航按钮
        UIButton *backbtn = [UIButton buttonWithType:UIButtonTypeCustom];
        //右导航按钮
        UIButton *rightBut = [UIButton buttonWithType:UIButtonTypeCustom];
        
        if(IOS_VERSION >= 7.0)
        {
            indicateView.backgroundColor = [UIColor colorWithHexadecimalString:@"#f7f7f7" withColorAlpha:1.0];
            //[UIColor colorWithPatternImage:[UIImage imageNamed:@"public_top_bar_ios7.png"]];
            self.titleTextLb.frame = CGRectMake(50,20, 220, NAVIGATION_TITLE_HEIGHT);
            backbtn.frame = CGRectMake(10,20, 50, 44);
            rightBut.frame = CGRectMake(self.view.frame.size.width - 50 - 10, 20, 45, 44);
        }
        else
        {
            indicateView.backgroundColor = [UIColor colorWithHexadecimalString:@"#f7f7f7" withColorAlpha:1.0];
            self.titleTextLb.frame = CGRectMake(50,self.view.frame.origin.y,220, NAVIGATION_TITLE_HEIGHT);
            backbtn.frame = CGRectMake(10, 0, 50, 44);
            rightBut.frame = CGRectMake(self.view.frame.size.width - 50 - 10, 0, 45, 44);
        }
        
        self.view.backgroundColor = [UIColor colorWithHexadecimalString:@"#EBEBEB" withColorAlpha:1.0];
        
        //Title区域显示标题
        [self.titleTextLb setBackgroundColor:[UIColor clearColor]];
        [self.titleTextLb setTextAlignment:NSTextAlignmentCenter];
        [self.titleTextLb setFont:[UIFont fontWithName:@"Helvetica-Bold"size:17.0]];
        [self.titleTextLb setTextColor:[UIColor colorWithHexadecimalString:@"#1a1a1a"withColorAlpha:1]];
        [indicateView addSubview:self.titleTextLb];
        
//        if (self.isToRoomChat)
//        {
//            
//            NSMutableArray *dataArray = [[IWxChatMgrGroup sharedGroup] getContactGroups];
//            for (ChatGroup *chatGroup in dataArray) {
//                if ([chatGroup.group_id isEqualToString:self.toChatGroup.group_id]) {
//                    self.titleTextLb.text = chatGroup.group_name;
//                    break;
//                }
//            }
//        }
//        else
//        {
//            self.titleTextLb.text = self.toChatContact.ContactName;
//        }
        
        self.titleTextLb.text = @"Join a Group";
        
        // 左导航按钮
        backbtn.backgroundColor = [UIColor clearColor];
//        [backbtn setImage:[UIImage imageNamed:@"back_button"] forState:UIControlStateNormal];
//        [backbtn setImage:[UIImage imageNamed:@"back_button"] forState:UIControlStateHighlighted];
        [backbtn setTitle:@"Cancel" forState:UIControlStateNormal];
        [backbtn.titleLabel setFont:[UIFont fontWithName:@"Helvetica"size:14.0]];
        [backbtn setTitleColor:[UIColor colorWithHexadecimalString:@"#1a1a1a" withColorAlpha:1] forState:UIControlStateNormal];
        [backbtn addTarget:self action: @selector(cancelButton:) forControlEvents: UIControlEventTouchUpInside];
        [indicateView addSubview:backbtn];
        
        //右导航按钮
//        UIImage *navRightImage = [UIImage imageNamed:@"ChatVC_right_Btn_N.png"];
//        [rightBut setImage:navRightImage forState:UIControlStateNormal]; //90 X88
//        [rightBut setImage:navRightImage forState:UIControlStateHighlighted];
        [rightBut setTitle:@"Create" forState:UIControlStateNormal];
        [rightBut setTitle:@"Create" forState:UIControlStateHighlighted];
        [rightBut.titleLabel setFont:[UIFont fontWithName:@"Helvetica" size:14.0]];
        [rightBut setTitleColor:[UIColor colorWithHexadecimalString:@"#1a1a1a" withColorAlpha:1] forState:UIControlStateNormal];
        rightBut.userInteractionEnabled = YES;

        [rightBut addTarget:self action:@selector(createButton:)forControlEvents:UIControlEventTouchUpInside];
        [indicateView addSubview:rightBut];

        [self.view addSubview:indicateView];
        
//        UIImageView *sepLine = [[UIImageView alloc] initWithFrame:CGRectMake(10, CGRectGetHeight(indicateView.frame)-1, 300, 1)];
//        sepLine.image = [UIImage imageNamed:@"Common_separate_line_thin.png"];
//        [indicateView addSubview:sepLine];
    }
}

- (void)cancelButton:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)createButton:(id)sender
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Create a New Group" message:@"Enter a name for this private group" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    alert.backgroundColor = [UIColor blueColor];
    [alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)//cancel按钮
    {
        return;
    }
    else if(buttonIndex == 1)//ok按钮
    {
        MainViewController *mainView = [[MainViewController alloc] init];
        //        examController.dataArr = dataArr;
        //        examController.delegate = self;
        
        [self dismissViewControllerAnimated:YES completion:^{
            
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
